package org.jeecg.modules.demo.spcWeeklyPlan.service.impl;

import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.demo.spcWeeklyPlan.entity.SpcWeeklyPlan;
import org.jeecg.modules.demo.spcWeeklyPlan.entity.SpcWeeklyPlanDetail;
import org.jeecg.modules.demo.spcWeeklyPlan.mapper.SpcWeeklyPlanDetailMapper;
import org.jeecg.modules.demo.spcWeeklyPlan.mapper.SpcWeeklyPlanMapper;
import org.jeecg.modules.demo.spcWeeklyPlan.service.ISpcWeeklyPlanService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.jeecg.modules.demo.utils.generateOddUtil;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;

/**
 * @Description: 周计划
 * @Author: jeecg-boot
 * @Date:   2023-10-23
 * @Version: V1.0
 */
@Service
public class SpcWeeklyPlanServiceImpl extends ServiceImpl<SpcWeeklyPlanMapper, SpcWeeklyPlan> implements ISpcWeeklyPlanService {

	@Resource
	private SpcWeeklyPlanMapper spcWeeklyPlanMapper;
	@Resource
	private SpcWeeklyPlanDetailMapper spcWeeklyPlanDetailMapper;


	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		spcWeeklyPlanDetailMapper.deleteByMainId(id);
		spcWeeklyPlanMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			spcWeeklyPlanDetailMapper.deleteByMainId(id.toString());
			spcWeeklyPlanMapper.deleteById(id);
		}
	}



	@Override
	public int generatedWeekPlan(String conNum) {
		List conNumList = null;
		conNumList = spcWeeklyPlanMapper.generatedWeekPlan(conNum);
		return conNumList.size();
	}

}
